home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: *Pointer to Functions(); /* HELP */
- Date: Mon, 22 Jan 96 13:38:45 GMT
- Organization: none
- Message-ID: <822317925snz@genesis.demon.co.uk>
- References: <4dvrq8$c2c@news.unicomp.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4dvrq8$c2c@news.unicomp.net> jgore@conline.com "Jerry_Gore" writes:
-
- >How do I pass a pointer to a funtion?
- >The following is found in a program:
- >
- > #define WORD unsigned int
- > void InstallTimer0(WORD period,void far (*func)(void));
- >
- >My function is thus:
- >
- > void far animate(void) /* I added 'far' for no good reason. */
- > { /* It uses that name in InstallTimer0. */
-
- Bad news as far as comp.lang.c is concerned - 'far' is not part of the
- C language.
-
- > /* do what ever */
- > return;
- > }
- >
- >How do I send InstallTimer0 the pointer to my function animate ???
- >I tried:
- >
- > InstallTimer0(120 , (*animate)());
-
- Simply use:
-
- InstallTimer0(120 , animate);
-
- A function name (or indeed any expression that designates a function)
- evaluates to a pointer to the function in equivalent circumstances where
- an array name/expression evaluates to a pointer to the first element
- of the array. () as an operator calls the function, if you don't want
- to do that you don't use ().
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-